<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Module      :  GHC.IO.Encoding.Failure</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 2008-2011</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-9"></span><span class="hs-comment">--</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Types for specifying how text encoding/decoding fails</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.Encoding.Failure</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-19"></span><span>    </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#CodingFailureMode"><span class="hs-identifier">CodingFailureMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#codingFailureModeSuffix"><span class="hs-identifier">codingFailureModeSuffix</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>    </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#isSurrogate"><span class="hs-identifier">isSurrogate</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>    </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#recoverDecode"><span class="hs-identifier">recoverDecode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#recoverEncode"><span class="hs-identifier">recoverEncode</span></a></span><span>
</span><span id="line-22"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html"><span class="hs-identifier">GHC.IO.Buffer</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Exception.html"><span class="hs-identifier">GHC.IO.Exception</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Char.html"><span class="hs-identifier">GHC.Char</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Word.html"><span class="hs-identifier">GHC.Word</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Show.html"><span class="hs-identifier">GHC.Show</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Num.html"><span class="hs-identifier">GHC.Num</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Real.html"><span class="hs-identifier">GHC.Real</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier">fromIntegral</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-comment">--import System.Posix.Internals</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-comment">-- | The 'CodingFailureMode' is used to construct 'System.IO.TextEncoding's,</span><span>
</span><span id="line-38"></span><span class="hs-comment">-- and specifies how they handle illegal sequences.</span><span>
</span><span id="line-39"></span><span class="hs-keyword">data</span><span> </span><span id="CodingFailureMode"><span class="annot"><a href="GHC.IO.Encoding.Failure.html#CodingFailureMode"><span class="hs-identifier hs-var">CodingFailureMode</span></a></span></span><span>
</span><span id="line-40"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="ErrorOnCodingFailure"><span class="annot"><a href="GHC.IO.Encoding.Failure.html#ErrorOnCodingFailure"><span class="hs-identifier hs-var">ErrorOnCodingFailure</span></a></span></span><span>
</span><span id="line-41"></span><span>       </span><span class="hs-comment">-- ^ Throw an error when an illegal sequence is encountered</span><span>
</span><span id="line-42"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="IgnoreCodingFailure"><span class="annot"><a href="GHC.IO.Encoding.Failure.html#IgnoreCodingFailure"><span class="hs-identifier hs-var">IgnoreCodingFailure</span></a></span></span><span>
</span><span id="line-43"></span><span>       </span><span class="hs-comment">-- ^ Attempt to ignore and recover if an illegal sequence is</span><span>
</span><span id="line-44"></span><span>       </span><span class="hs-comment">-- encountered</span><span>
</span><span id="line-45"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="TransliterateCodingFailure"><span class="annot"><a href="GHC.IO.Encoding.Failure.html#TransliterateCodingFailure"><span class="hs-identifier hs-var">TransliterateCodingFailure</span></a></span></span><span>
</span><span id="line-46"></span><span>       </span><span class="hs-comment">-- ^ Replace with the closest visual match upon an illegal</span><span>
</span><span id="line-47"></span><span>       </span><span class="hs-comment">-- sequence</span><span>
</span><span id="line-48"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="RoundtripFailure"><span class="annot"><a href="GHC.IO.Encoding.Failure.html#RoundtripFailure"><span class="hs-identifier hs-var">RoundtripFailure</span></a></span></span><span>
</span><span id="line-49"></span><span>       </span><span class="hs-comment">-- ^ Use the private-use escape mechanism to attempt to allow</span><span>
</span><span id="line-50"></span><span>       </span><span class="hs-comment">-- illegal sequences to be roundtripped.</span><span>
</span><span id="line-51"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span> </span><span id="local-6989586621679545449"><span id="local-6989586621679545451"><span id="local-6989586621679545453"><span class="annot"><span class="annottext">Int -&gt; CodingFailureMode -&gt; ShowS
[CodingFailureMode] -&gt; ShowS
CodingFailureMode -&gt; String
(Int -&gt; CodingFailureMode -&gt; ShowS)
-&gt; (CodingFailureMode -&gt; String)
-&gt; ([CodingFailureMode] -&gt; ShowS)
-&gt; Show CodingFailureMode
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; String) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [CodingFailureMode] -&gt; ShowS
$cshowList :: [CodingFailureMode] -&gt; ShowS
show :: CodingFailureMode -&gt; String
$cshow :: CodingFailureMode -&gt; String
showsPrec :: Int -&gt; CodingFailureMode -&gt; ShowS
$cshowsPrec :: Int -&gt; CodingFailureMode -&gt; ShowS
</span><a href="GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.4.0.0</span><span>
</span><span id="line-52"></span><span>           </span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span>       </span><span class="hs-comment">-- This will only work properly for those encodings which are</span><span>
</span><span id="line-54"></span><span>       </span><span class="hs-comment">-- strict supersets of ASCII in the sense that valid ASCII data</span><span>
</span><span id="line-55"></span><span>       </span><span class="hs-comment">-- is also valid in that encoding. This is not true for</span><span>
</span><span id="line-56"></span><span>       </span><span class="hs-comment">-- e.g. UTF-16, because ASCII characters must be padded to two</span><span>
</span><span id="line-57"></span><span>       </span><span class="hs-comment">-- bytes to retain their meaning.</span><span>
</span><span id="line-58"></span><span>
</span><span id="line-59"></span><span class="hs-comment">-- Note [Roundtripping]</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-61"></span><span class="hs-comment">--</span><span>
</span><span id="line-62"></span><span class="hs-comment">-- Roundtripping is based on the ideas of PEP383.</span><span>
</span><span id="line-63"></span><span class="hs-comment">--</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- We used to use the range of private-use characters from 0xEF80 to</span><span>
</span><span id="line-65"></span><span class="hs-comment">-- 0xEFFF designated for &quot;encoding hacks&quot; by the ConScript Unicode Registery</span><span>
</span><span id="line-66"></span><span class="hs-comment">-- to encode these characters.</span><span>
</span><span id="line-67"></span><span class="hs-comment">--</span><span>
</span><span id="line-68"></span><span class="hs-comment">-- However, people didn't like this because it means we don't get</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- guaranteed roundtripping for byte sequences that look like a UTF-8</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- encoded codepoint 0xEFxx.</span><span>
</span><span id="line-71"></span><span class="hs-comment">--</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- So now like PEP383 we use lone surrogate codepoints 0xDCxx to escape</span><span>
</span><span id="line-73"></span><span class="hs-comment">-- undecodable bytes, even though that may confuse Unicode processing</span><span>
</span><span id="line-74"></span><span class="hs-comment">-- software written in Haskell. This guarantees roundtripping because</span><span>
</span><span id="line-75"></span><span class="hs-comment">-- unicode input that includes lone surrogate codepoints is invalid by</span><span>
</span><span id="line-76"></span><span class="hs-comment">-- definition.</span><span>
</span><span id="line-77"></span><span class="hs-comment">--</span><span>
</span><span id="line-78"></span><span class="hs-comment">--</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- When we used private-use characters there was a technical problem when it</span><span>
</span><span id="line-80"></span><span class="hs-comment">-- came to encoding back to bytes using iconv. The iconv code will not fail when</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- it tries to encode a private-use character (as it would if trying to encode</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- a surrogate), which means that we wouldn't get a chance to replace it</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- with the byte we originally escaped.</span><span>
</span><span id="line-84"></span><span class="hs-comment">--</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- To work around this, when filling the buffer to be encoded (in</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- writeBlocks/withEncodedCString/newEncodedCString), we replaced the</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- private-use characters with lone surrogates again! Likewise, when</span><span>
</span><span id="line-88"></span><span class="hs-comment">-- reading from a buffer (unpack/unpack_nl/peekEncodedCString) we had</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- to do the inverse process.</span><span>
</span><span id="line-90"></span><span class="hs-comment">--</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- The user of String would never see these lone surrogates, but it</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- ensured that iconv will throw an error when encountering them.  We</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- used lone surrogates in the range 0xDC00 to 0xDCFF for this purpose.</span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#codingFailureModeSuffix"><span class="hs-identifier hs-type">codingFailureModeSuffix</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#CodingFailureMode"><span class="hs-identifier hs-type">CodingFailureMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-96"></span><span id="codingFailureModeSuffix"><span class="annot"><span class="annottext">codingFailureModeSuffix :: CodingFailureMode -&gt; String
</span><a href="GHC.IO.Encoding.Failure.html#codingFailureModeSuffix"><span class="hs-identifier hs-var hs-var">codingFailureModeSuffix</span></a></span></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#ErrorOnCodingFailure"><span class="hs-identifier hs-var">ErrorOnCodingFailure</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span>
</span><span id="line-97"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#codingFailureModeSuffix"><span class="hs-identifier hs-var">codingFailureModeSuffix</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#IgnoreCodingFailure"><span class="hs-identifier hs-var">IgnoreCodingFailure</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;//IGNORE&quot;</span></span><span>
</span><span id="line-98"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#codingFailureModeSuffix"><span class="hs-identifier hs-var">codingFailureModeSuffix</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#TransliterateCodingFailure"><span class="hs-identifier hs-var">TransliterateCodingFailure</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;//TRANSLIT&quot;</span></span><span>
</span><span id="line-99"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#codingFailureModeSuffix"><span class="hs-identifier hs-var">codingFailureModeSuffix</span></a></span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#RoundtripFailure"><span class="hs-identifier hs-var">RoundtripFailure</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;//ROUNDTRIP&quot;</span></span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span><span class="hs-comment">-- | In transliterate mode, we use this character when decoding</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- unknown bytes.</span><span>
</span><span id="line-103"></span><span class="hs-comment">--</span><span>
</span><span id="line-104"></span><span class="hs-comment">-- This is the defined Unicode replacement character:</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- &lt;http://www.fileformat.info/info/unicode/char/0fffd/index.htm&gt;</span><span>
</span><span id="line-106"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#unrepresentableChar"><span class="hs-identifier hs-type">unrepresentableChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span>
</span><span id="line-107"></span><span id="unrepresentableChar"><span class="annot"><span class="annottext">unrepresentableChar :: Char
</span><a href="GHC.IO.Encoding.Failure.html#unrepresentableChar"><span class="hs-identifier hs-var hs-var">unrepresentableChar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\xFFFD'</span></span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span class="hs-comment">-- It is extraordinarily important that this series of</span><span>
</span><span id="line-110"></span><span class="hs-comment">-- predicates/transformers gets inlined, because they tend to be used</span><span>
</span><span id="line-111"></span><span class="hs-comment">-- in inner loops related to text encoding. In particular,</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- surrogatifyRoundtripCharacter must be inlined (see #5536)</span><span>
</span><span id="line-113"></span><span>
</span><span id="line-114"></span><span class="hs-comment">-- | Some characters are actually &quot;surrogate&quot; codepoints defined for</span><span>
</span><span id="line-115"></span><span class="hs-comment">-- use in UTF-16. We need to signal an invalid character if we detect</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- them when encoding a sequence of 'Char's into 'Word8's because they</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- won't give valid Unicode.</span><span>
</span><span id="line-118"></span><span class="hs-comment">--</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- We may also need to signal an invalid character if we detect them</span><span>
</span><span id="line-120"></span><span class="hs-comment">-- when encoding a sequence of 'Char's into 'Word8's because the</span><span>
</span><span id="line-121"></span><span class="hs-comment">-- 'RoundtripFailure' mode creates these to round-trip bytes through</span><span>
</span><span id="line-122"></span><span class="hs-comment">-- our internal UTF-16 encoding.</span><span>
</span><span id="line-123"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#isSurrogate"><span class="hs-pragma hs-type">isSurrogate</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-124"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#isSurrogate"><span class="hs-identifier hs-type">isSurrogate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-125"></span><span id="isSurrogate"><span class="annot"><span class="annottext">isSurrogate :: Char -&gt; Bool
</span><a href="GHC.IO.Encoding.Failure.html#isSurrogate"><span class="hs-identifier hs-var hs-var">isSurrogate</span></a></span></span><span> </span><span id="local-6989586621679545446"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679545446"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xD800</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545444"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545444"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xDBFF</span></span><span class="hs-special">)</span><span>
</span><span id="line-126"></span><span>             </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xDC00</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545444"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545444"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xDFFF</span></span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679545444"><span class="annot"><span class="annottext">x :: Int
</span><a href="#local-6989586621679545444"><span class="hs-identifier hs-var hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679545446"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span class="hs-comment">-- Bytes (in Buffer Word8) --&gt; lone surrogates (in Buffer CharBufElem)</span><span>
</span><span id="line-130"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#escapeToRoundtripCharacterSurrogate"><span class="hs-pragma hs-type">escapeToRoundtripCharacterSurrogate</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-131"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#escapeToRoundtripCharacterSurrogate"><span class="hs-identifier hs-type">escapeToRoundtripCharacterSurrogate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span>
</span><span id="line-132"></span><span id="escapeToRoundtripCharacterSurrogate"><span class="annot"><span class="annottext">escapeToRoundtripCharacterSurrogate :: Word8 -&gt; Char
</span><a href="GHC.IO.Encoding.Failure.html#escapeToRoundtripCharacterSurrogate"><span class="hs-identifier hs-var hs-var">escapeToRoundtripCharacterSurrogate</span></a></span></span><span> </span><span id="local-6989586621679545439"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679545439"><span class="hs-identifier hs-var">b</span></a></span></span><span>
</span><span id="line-133"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679545439"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">128</span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Char
</span><a href="GHC.Char.html#chr"><span class="hs-identifier hs-var">chr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679545439"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-134"></span><span>      </span><span class="hs-comment">-- Disallow 'smuggling' of ASCII bytes. For roundtripping to</span><span>
</span><span id="line-135"></span><span>      </span><span class="hs-comment">-- work, this assumes encoding is ASCII-superset.</span><span>
</span><span id="line-136"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Char
</span><a href="GHC.Char.html#chr"><span class="hs-identifier hs-var">chr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xDC00</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679545439"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-137"></span><span>
</span><span id="line-138"></span><span class="hs-comment">-- Lone surrogates (in Buffer CharBufElem) --&gt; bytes (in Buffer Word8)</span><span>
</span><span id="line-139"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#unescapeRoundtripCharacterSurrogate"><span class="hs-pragma hs-type">unescapeRoundtripCharacterSurrogate</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-140"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#unescapeRoundtripCharacterSurrogate"><span class="hs-identifier hs-type">unescapeRoundtripCharacterSurrogate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-141"></span><span id="unescapeRoundtripCharacterSurrogate"><span class="annot"><span class="annottext">unescapeRoundtripCharacterSurrogate :: Char -&gt; Maybe Word8
</span><a href="GHC.IO.Encoding.Failure.html#unescapeRoundtripCharacterSurrogate"><span class="hs-identifier hs-var hs-var">unescapeRoundtripCharacterSurrogate</span></a></span></span><span> </span><span id="local-6989586621679545434"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679545434"><span class="hs-identifier hs-var">c</span></a></span></span><span>
</span><span id="line-142"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xDC80</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545433"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545433"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xDD00</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Maybe Word8
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Word8
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545433"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Discard high byte</span><span>
</span><span id="line-143"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Word8
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-144"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679545433"><span class="annot"><span class="annottext">x :: Int
</span><a href="#local-6989586621679545433"><span class="hs-identifier hs-var hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679545434"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-145"></span><span>
</span><span id="line-146"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#recoverDecode"><span class="hs-identifier hs-type">recoverDecode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#CodingFailureMode"><span class="hs-identifier hs-type">CodingFailureMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span>
</span><span id="line-147"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span id="recoverDecode"><span class="annot"><span class="annottext">recoverDecode :: CodingFailureMode
-&gt; Buffer Word8 -&gt; Buffer Char -&gt; IO (Buffer Word8, Buffer Char)
</span><a href="GHC.IO.Encoding.Failure.html#recoverDecode"><span class="hs-identifier hs-var hs-var">recoverDecode</span></a></span></span><span> </span><span id="local-6989586621679545432"><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679545432"><span class="hs-identifier hs-var">cfm</span></a></span></span><span> </span><span id="local-6989586621679545431"><span class="annot"><span class="annottext">input :: Buffer Word8
</span><a href="#local-6989586621679545431"><span class="hs-identifier hs-var">input</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span class="hs-special">{</span><span>  </span><span class="annot"><span class="annottext">bufRaw :: forall e. Buffer e -&gt; RawBuffer e
</span><a href="GHC.IO.Buffer.html#bufRaw"><span class="hs-identifier hs-var">bufRaw</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679545428"><span class="annot"><span class="annottext">RawBuffer Word8
</span><a href="#local-6989586621679545428"><span class="hs-identifier hs-var">iraw</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufL :: forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679545426"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545426"><span class="hs-identifier hs-var">ir</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufR :: forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufR"><span class="hs-identifier hs-var">bufR</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-149"></span><span>                  </span><span id="local-6989586621679545424"><span class="annot"><span class="annottext">output :: Buffer Char
</span><a href="#local-6989586621679545424"><span class="hs-identifier hs-var">output</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufRaw :: forall e. Buffer e -&gt; RawBuffer e
</span><a href="GHC.IO.Buffer.html#bufRaw"><span class="hs-identifier hs-var">bufRaw</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679545423"><span class="annot"><span class="annottext">RawBuffer Char
</span><a href="#local-6989586621679545423"><span class="hs-identifier hs-var">oraw</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufL :: forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span>  </span><span class="annot"><span class="annottext">bufR :: forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufR"><span class="hs-identifier hs-var">bufR</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679545422"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545422"><span class="hs-identifier hs-var">ow</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-150"></span><span> </span><span class="hs-comment">--puts $ &quot;recoverDecode &quot; ++ show ir</span><span>
</span><span id="line-151"></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679545432"><span class="hs-identifier hs-var">cfm</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-152"></span><span>  </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#ErrorOnCodingFailure"><span class="hs-identifier hs-var">ErrorOnCodingFailure</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO (Buffer Word8, Buffer Char)
forall a. IO a
</span><a href="GHC.IO.Encoding.Failure.html#ioe_decodingError"><span class="hs-identifier hs-var">ioe_decodingError</span></a></span><span>
</span><span id="line-153"></span><span>  </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#IgnoreCodingFailure"><span class="hs-identifier hs-var">IgnoreCodingFailure</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Buffer Word8, Buffer Char) -&gt; IO (Buffer Word8, Buffer Char)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679545431"><span class="hs-identifier hs-var">input</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufL :: Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545426"><span class="hs-identifier hs-var">ir</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer Char
</span><a href="#local-6989586621679545424"><span class="hs-identifier hs-var">output</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>  </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#TransliterateCodingFailure"><span class="hs-identifier hs-var">TransliterateCodingFailure</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-155"></span><span>      </span><span id="local-6989586621679545420"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545420"><span class="hs-identifier hs-var">ow'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RawBuffer Char -&gt; Int -&gt; Char -&gt; IO Int
</span><a href="GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer Char
</span><a href="#local-6989586621679545423"><span class="hs-identifier hs-var">oraw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545422"><span class="hs-identifier hs-var">ow</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="GHC.IO.Encoding.Failure.html#unrepresentableChar"><span class="hs-identifier hs-var">unrepresentableChar</span></a></span><span>
</span><span id="line-156"></span><span>      </span><span class="annot"><span class="annottext">(Buffer Word8, Buffer Char) -&gt; IO (Buffer Word8, Buffer Char)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679545431"><span class="hs-identifier hs-var">input</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufL :: Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545426"><span class="hs-identifier hs-var">ir</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer Char
</span><a href="#local-6989586621679545424"><span class="hs-identifier hs-var">output</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufR :: Int
</span><a href="GHC.IO.Buffer.html#bufR"><span class="hs-identifier hs-var">bufR</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545420"><span class="hs-identifier hs-var">ow'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-157"></span><span>  </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#RoundtripFailure"><span class="hs-identifier hs-var">RoundtripFailure</span></a></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-158"></span><span>      </span><span id="local-6989586621679545418"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679545418"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RawBuffer Word8 -&gt; Int -&gt; IO Word8
</span><a href="GHC.IO.Buffer.html#readWord8Buf"><span class="hs-identifier hs-var">readWord8Buf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer Word8
</span><a href="#local-6989586621679545428"><span class="hs-identifier hs-var">iraw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545426"><span class="hs-identifier hs-var">ir</span></a></span><span>
</span><span id="line-159"></span><span>      </span><span id="local-6989586621679545416"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545416"><span class="hs-identifier hs-var">ow'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RawBuffer Char -&gt; Int -&gt; Char -&gt; IO Int
</span><a href="GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer Char
</span><a href="#local-6989586621679545423"><span class="hs-identifier hs-var">oraw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545422"><span class="hs-identifier hs-var">ow</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Char
</span><a href="GHC.IO.Encoding.Failure.html#escapeToRoundtripCharacterSurrogate"><span class="hs-identifier hs-var">escapeToRoundtripCharacterSurrogate</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679545418"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-160"></span><span>      </span><span class="annot"><span class="annottext">(Buffer Word8, Buffer Char) -&gt; IO (Buffer Word8, Buffer Char)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679545431"><span class="hs-identifier hs-var">input</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufL :: Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545426"><span class="hs-identifier hs-var">ir</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer Char
</span><a href="#local-6989586621679545424"><span class="hs-identifier hs-var">output</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufR :: Int
</span><a href="GHC.IO.Buffer.html#bufR"><span class="hs-identifier hs-var">bufR</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545416"><span class="hs-identifier hs-var">ow'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-161"></span><span>
</span><span id="line-162"></span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#recoverEncode"><span class="hs-identifier hs-type">recoverEncode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.IO.Encoding.Failure.html#CodingFailureMode"><span class="hs-identifier hs-type">CodingFailureMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-163"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-164"></span><span id="recoverEncode"><span class="annot"><span class="annottext">recoverEncode :: CodingFailureMode
-&gt; Buffer Char -&gt; Buffer Word8 -&gt; IO (Buffer Char, Buffer Word8)
</span><a href="GHC.IO.Encoding.Failure.html#recoverEncode"><span class="hs-identifier hs-var hs-var">recoverEncode</span></a></span></span><span> </span><span id="local-6989586621679545415"><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679545415"><span class="hs-identifier hs-var">cfm</span></a></span></span><span> </span><span id="local-6989586621679545414"><span class="annot"><span class="annottext">input :: Buffer Char
</span><a href="#local-6989586621679545414"><span class="hs-identifier hs-var">input</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span class="hs-special">{</span><span>  </span><span class="annot"><span class="annottext">bufRaw :: forall e. Buffer e -&gt; RawBuffer e
</span><a href="GHC.IO.Buffer.html#bufRaw"><span class="hs-identifier hs-var">bufRaw</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679545413"><span class="annot"><span class="annottext">RawBuffer Char
</span><a href="#local-6989586621679545413"><span class="hs-identifier hs-var">iraw</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufL :: forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679545412"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545412"><span class="hs-identifier hs-var">ir</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufR :: forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufR"><span class="hs-identifier hs-var">bufR</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-165"></span><span>                  </span><span id="local-6989586621679545411"><span class="annot"><span class="annottext">output :: Buffer Word8
</span><a href="#local-6989586621679545411"><span class="hs-identifier hs-var">output</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufRaw :: forall e. Buffer e -&gt; RawBuffer e
</span><a href="GHC.IO.Buffer.html#bufRaw"><span class="hs-identifier hs-var">bufRaw</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679545410"><span class="annot"><span class="annottext">RawBuffer Word8
</span><a href="#local-6989586621679545410"><span class="hs-identifier hs-var">oraw</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufL :: forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span>  </span><span class="annot"><span class="annottext">bufR :: forall e. Buffer e -&gt; Int
</span><a href="GHC.IO.Buffer.html#bufR"><span class="hs-identifier hs-var">bufR</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679545409"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545409"><span class="hs-identifier hs-var">ow</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-166"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621679545408"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679545408"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679545407"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545407"><span class="hs-identifier hs-var">ir'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RawBuffer Char -&gt; Int -&gt; IO (Char, Int)
</span><a href="GHC.IO.Buffer.html#readCharBuf"><span class="hs-identifier hs-var">readCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer Char
</span><a href="#local-6989586621679545413"><span class="hs-identifier hs-var">iraw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545412"><span class="hs-identifier hs-var">ir</span></a></span><span>
</span><span id="line-167"></span><span>  </span><span class="hs-comment">--puts $ &quot;recoverEncode &quot; ++ show ir ++ &quot; &quot; ++ show ir'</span><span>
</span><span id="line-168"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="#local-6989586621679545415"><span class="hs-identifier hs-var">cfm</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-169"></span><span>    </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#IgnoreCodingFailure"><span class="hs-identifier hs-var">IgnoreCodingFailure</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Buffer Char, Buffer Word8) -&gt; IO (Buffer Char, Buffer Word8)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Char
</span><a href="#local-6989586621679545414"><span class="hs-identifier hs-var">input</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufL :: Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545407"><span class="hs-identifier hs-var">ir'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679545411"><span class="hs-identifier hs-var">output</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span>    </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#TransliterateCodingFailure"><span class="hs-identifier hs-var">TransliterateCodingFailure</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-171"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679545408"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'?'</span></span><span>
</span><span id="line-172"></span><span>         </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">(Buffer Char, Buffer Word8) -&gt; IO (Buffer Char, Buffer Word8)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Char
</span><a href="#local-6989586621679545414"><span class="hs-identifier hs-var">input</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufL :: Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545407"><span class="hs-identifier hs-var">ir'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679545411"><span class="hs-identifier hs-var">output</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-173"></span><span>         </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-174"></span><span>          </span><span class="hs-comment">-- XXX: evil hack! To implement transliteration, we just</span><span>
</span><span id="line-175"></span><span>          </span><span class="hs-comment">-- poke an ASCII ? into the input buffer and tell the caller</span><span>
</span><span id="line-176"></span><span>          </span><span class="hs-comment">-- to try and decode again. This is *probably* safe given</span><span>
</span><span id="line-177"></span><span>          </span><span class="hs-comment">-- current uses of TextEncoding.</span><span>
</span><span id="line-178"></span><span>          </span><span class="hs-comment">--</span><span>
</span><span id="line-179"></span><span>          </span><span class="hs-comment">-- The &quot;if&quot; test above ensures we skip if the encoding fails</span><span>
</span><span id="line-180"></span><span>          </span><span class="hs-comment">-- to deal with the ?, though this should never happen in</span><span>
</span><span id="line-181"></span><span>          </span><span class="hs-comment">-- practice as all encodings are in fact capable of</span><span>
</span><span id="line-182"></span><span>          </span><span class="hs-comment">-- reperesenting all ASCII characters.</span><span>
</span><span id="line-183"></span><span>          </span><span id="local-6989586621679545405"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545405"><span class="hs-identifier hs-var">_ir'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RawBuffer Char -&gt; Int -&gt; Char -&gt; IO Int
</span><a href="GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer Char
</span><a href="#local-6989586621679545413"><span class="hs-identifier hs-var">iraw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545412"><span class="hs-identifier hs-var">ir</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'?'</span></span><span>
</span><span id="line-184"></span><span>          </span><span class="annot"><span class="annottext">(Buffer Char, Buffer Word8) -&gt; IO (Buffer Char, Buffer Word8)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Char
</span><a href="#local-6989586621679545414"><span class="hs-identifier hs-var">input</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679545411"><span class="hs-identifier hs-var">output</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span>        </span><span class="hs-comment">-- This implementation does not work because e.g. UTF-16</span><span>
</span><span id="line-187"></span><span>        </span><span class="hs-comment">-- requires 2 bytes to encode a simple ASCII value</span><span>
</span><span id="line-188"></span><span>        </span><span class="hs-comment">--writeWord8Buf oraw ow unrepresentableByte</span><span>
</span><span id="line-189"></span><span>        </span><span class="hs-comment">--return (input { bufL=ir' }, output { bufR=ow+1 })</span><span>
</span><span id="line-190"></span><span>    </span><span class="annot"><span class="annottext">CodingFailureMode
</span><a href="GHC.IO.Encoding.Failure.html#RoundtripFailure"><span class="hs-identifier hs-var">RoundtripFailure</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679545404"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679545404"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Maybe Word8
</span><a href="GHC.IO.Encoding.Failure.html#unescapeRoundtripCharacterSurrogate"><span class="hs-identifier hs-var">unescapeRoundtripCharacterSurrogate</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679545408"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-191"></span><span>        </span><span class="annot"><span class="annottext">RawBuffer Word8 -&gt; Int -&gt; Word8 -&gt; IO ()
</span><a href="GHC.IO.Buffer.html#writeWord8Buf"><span class="hs-identifier hs-var">writeWord8Buf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer Word8
</span><a href="#local-6989586621679545410"><span class="hs-identifier hs-var">oraw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545409"><span class="hs-identifier hs-var">ow</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679545404"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-192"></span><span>        </span><span class="annot"><span class="annottext">(Buffer Char, Buffer Word8) -&gt; IO (Buffer Char, Buffer Word8)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer Char
</span><a href="#local-6989586621679545414"><span class="hs-identifier hs-var">input</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufL :: Int
</span><a href="GHC.IO.Buffer.html#bufL"><span class="hs-identifier hs-var">bufL</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545407"><span class="hs-identifier hs-var">ir'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer Word8
</span><a href="#local-6989586621679545411"><span class="hs-identifier hs-var">output</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">bufR :: Int
</span><a href="GHC.IO.Buffer.html#bufR"><span class="hs-identifier hs-var">bufR</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679545409"><span class="hs-identifier hs-var">ow</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-193"></span><span>    </span><span class="annot"><span class="annottext">CodingFailureMode
</span><span class="hs-identifier">_</span></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO (Buffer Char, Buffer Word8)
forall a. IO a
</span><a href="GHC.IO.Encoding.Failure.html#ioe_encodingError"><span class="hs-identifier hs-var">ioe_encodingError</span></a></span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span id="local-6989586621679545528"><span class="annot"><a href="GHC.IO.Encoding.Failure.html#ioe_decodingError"><span class="hs-identifier hs-type">ioe_decodingError</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679545528"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-196"></span><span id="ioe_decodingError"><span class="annot"><span class="annottext">ioe_decodingError :: forall a. IO a
</span><a href="GHC.IO.Encoding.Failure.html#ioe_decodingError"><span class="hs-identifier hs-var hs-var">ioe_decodingError</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO a
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span>
</span><span id="line-197"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
-&gt; IOErrorType
-&gt; String
-&gt; String
-&gt; Maybe CInt
-&gt; Maybe String
-&gt; IOException
</span><a href="GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-var">IOError</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="GHC.IO.Exception.html#InvalidArgument"><span class="hs-identifier hs-var">InvalidArgument</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;recoverDecode&quot;</span></span><span>
</span><span id="line-198"></span><span>        </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;invalid byte sequence&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe CInt
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-199"></span><span>
</span><span id="line-200"></span><span id="local-6989586621679545398"><span class="annot"><a href="GHC.IO.Encoding.Failure.html#ioe_encodingError"><span class="hs-identifier hs-type">ioe_encodingError</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679545398"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-201"></span><span id="ioe_encodingError"><span class="annot"><span class="annottext">ioe_encodingError :: forall a. IO a
</span><a href="GHC.IO.Encoding.Failure.html#ioe_encodingError"><span class="hs-identifier hs-var hs-var">ioe_encodingError</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO a
forall a. IOException -&gt; IO a
</span><a href="GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span>
</span><span id="line-202"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
-&gt; IOErrorType
-&gt; String
-&gt; String
-&gt; Maybe CInt
-&gt; Maybe String
-&gt; IOException
</span><a href="GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-var">IOError</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="GHC.IO.Exception.html#InvalidArgument"><span class="hs-identifier hs-var">InvalidArgument</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;recoverEncode&quot;</span></span><span>
</span><span id="line-203"></span><span>        </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;invalid character&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe CInt
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-204"></span><span>
</span><span id="line-205"></span></pre></body></html>